﻿using FirstWinform;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Main : Form
    {
        public Main()
        {
            InitializeComponent();
        }

        private void button10_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button28_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button29_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button12_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button13_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button14_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button15_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button11_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button16_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button77_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button75_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button74_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button73_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button72_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button71_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button70_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button69_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button17_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button18_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button109_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button108_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button107_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button106_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button105_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button104_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button103_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button102_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button101_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button76_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button61_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button60_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button59_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button58_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button57_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button56_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button55_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button54_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button53_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button45_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button44_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button43_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button42_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button41_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button40_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button39_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button38_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button37_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button29_Click_1(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button28_Click_1(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button27_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button26_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button25_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button24_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button23_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button22_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button21_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button93_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button92_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button91_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button90_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button89_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button88_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button87_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button86_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button85_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button141_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button140_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button139_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button138_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button137_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button136_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button135_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button134_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button133_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button125_Click(object sender, EventArgs e)
        {
            panel1.BringToFront();
        }

        private void button124_Click(object sender, EventArgs e)
        {
            panel2.BringToFront();
        }

        private void button123_Click(object sender, EventArgs e)
        {
            panel3.BringToFront();
        }

        private void button122_Click(object sender, EventArgs e)
        {
            panel4.BringToFront();
        }

        private void button121_Click(object sender, EventArgs e)
        {
            panel5.BringToFront();
        }

        private void button120_Click(object sender, EventArgs e)
        {
            panel6.BringToFront();
        }

        private void button119_Click(object sender, EventArgs e)
        {
            panel7.BringToFront();
        }

        private void button118_Click(object sender, EventArgs e)
        {
            panel8.BringToFront();
        }

        private void button117_Click(object sender, EventArgs e)
        {
            panel9.BringToFront();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            
        }

        private void button148_Click(object sender, EventArgs e)
        {
            panel10.BringToFront();
        }

        private void button149_Click(object sender, EventArgs e)
        {
            panel11.BringToFront();
        }

        private void Main_Load(object sender, EventArgs e)
        {
            string sql = "select * from Books";
            DataTable dt = DBHelper.GetDataTable(sql);
            dgv.DataSource = dt;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            panel12.BringToFront();
        }

        private void button2_Click(object sender, EventArgs e)
        {
          
        }

        private void button3_Click(object sender, EventArgs e)
        {
            
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            panel13.BringToFront();
        }

        private void button3_Click_1(object sender, EventArgs e)
        {
            panel14.BringToFront();
        }

        private void button153_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button154_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button155_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button156_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button157_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button158_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button150_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button151_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button152_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if(comboBox1.Text=="状态")
            {
                textBox1.Hide();
                comboBox2.Show();
                comboBox2.Items.Clear();
                comboBox2.Items.Add("存在"); comboBox2.Items.Add("封禁");
            }
            else if (comboBox1.Text == "按书籍类型")
            {
                textBox1.Hide();
                comboBox2.Show();
                comboBox2.Items.Clear();
                comboBox2.Items.Add("都市类"); comboBox2.Items.Add("古典类"); comboBox2.Items.Add("言情类"); comboBox2.Items.Add("玄幻类");
                comboBox2.Items.Add("奇幻类"); comboBox2.Items.Add("网游类"); comboBox2.Items.Add("同人类"); comboBox2.Items.Add("乡村爱情类");
            }
            else if (comboBox1.Text == "按书籍上架时间分类")
            {

                comboBox2.Items.Clear();
                textBox1.Hide();
                comboBox2.Show();
                comboBox2.Items.Clear();
            }
            else if (comboBox1.Text == "按作者分类")
            {
                textBox1.Hide();
                comboBox2.Show();
                comboBox2.Items.Clear();
                comboBox2.Items.Add("yq"); comboBox2.Items.Add("wqw"); comboBox2.Items.Add("yyb"); comboBox2.Items.Add("fjh");
            }
            else
            {
                comboBox2.Hide();
                textBox1.Show();
            }
        }

        private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void button160_Click(object sender, EventArgs e)
        {
            panel15.BringToFront();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void panel13_Paint(object sender, PaintEventArgs e)
        {

        }

        private void button159_Click(object sender, EventArgs e)
        {
            string name = textBox1.Text;
            if (comboBox1.Text=="按书籍名称")
            {
                string sql = string.Format("select * from Books where bookName like '%{0}%'",name);
                DataTable dt = DBHelper.GetDataTable(sql);
                dgv.DataSource = dt;
            }
            if (comboBox1.Text == "状态")
            {
                string zt = comboBox2.Text;
                string sql = string.Format("select * from Books where {0}",zt);
                DataTable dt = DBHelper.GetDataTable(sql);
                dgv.DataSource = dt;
            }
            if (comboBox1.Text == "按书籍类型")
            {
                string lx = comboBox2.Text;
                string sql = string.Format("select * from Books a join Fenlei b on a.bookFenlei=b.FenleiID where b.Fenlei='{0}'", lx);
                DataTable dt = DBHelper.GetDataTable(sql);
                dgv.DataSource = dt;
            }
            if (comboBox1.Text == "按书籍上架时间")
            {
                string sql = "select * from Books order by booktime desc";
                DataTable dt = DBHelper.GetDataTable(sql);
                dgv.DataSource = dt;
            }
            if (comboBox1.Text == "按作者分类")
            {
                string zz = comboBox2.Text;
                string sql = string.Format("select * from Books where bookzuozhe='{0}'",zz);
                DataTable dt = DBHelper.GetDataTable(sql);
                dgv.DataSource = dt;
            }

        }

        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox3.Items.Clear();
            comboBox3.Items.Add("都市类"); comboBox3.Items.Add("古典类"); comboBox3.Items.Add("言情类"); comboBox3.Items.Add("玄幻类");
            comboBox3.Items.Add("奇幻类"); comboBox3.Items.Add("网游类"); comboBox3.Items.Add("同人类"); comboBox3.Items.Add("乡村爱情类");
        }

        private void button162_Click(object sender, EventArgs e)
        {
            int fl=0;string nr = textBox3.Text;
            if (comboBox3.Text== "都市类")
            {
                fl = 1;
            }
            if (comboBox3.Text == "古典类")
            {
                fl = 2;
            }
            if (comboBox3.Text == "言情类")
            {
                fl = 3;
            }
            if (comboBox3.Text == "玄幻类")
            {
                fl = 4;
            }
            if (comboBox3.Text == "奇幻类")
            {
                fl = 5;
            }
            if (comboBox3.Text == "网游类")
            {
                fl = 6;
            }
            if (comboBox3.Text == "同人类")
            {
                fl = 7;
            }
            if (comboBox3.Text == "乡村爱情类")
            {
                fl = 8;
            }
            int zt=0;
            if (textBox6.Text=="待续")
            {
                zt = 1;
            }
            if (textBox6.Text == "完结")
            {
                zt = 2;
            }
            string k = "";
            string id = textBox9.Text;
            string name = textBox2.Text;
            string zz = textBox6.Text;
            string jj = textBox8.Text;


            string sql1 = string.Format("insert into ");

            string sql = string.Format("insert into Books values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')",id, fl, name,zz,k,zt,k,jj,k);
            if (DBHelper.ExecuteNonQuery(sql))
            {
                MessageBox.Show("添加成功");
            }
            else
            {
                MessageBox.Show("请联系管理员");
            }


        }
    }
}
